<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: ListController.php 2011-03-09 08:45:41Z idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 */

class Kowcore_ListController extends Core_Controller_Action_Standard {
	public function ratesAction() {
		$guid = $this->_getParam ( 'guid', '' );
		if (! $guid) {
			$this->view->status = false;
			$this->view->message = $this->view->translate ( 'Nobody rated it.' );
			return;
		}
		
		$this->view->page = $page = $this->_getParam ( 'page', 1 );
		
		$this->view->object = $object = Engine_Api::_ ()->getItemByGuid ( $guid );
		if (! $object->getIdentity ()) {
			$this->view->status = false;
			$this->view->message = $this->view->translate ( 'Correct parameters needed.' );
			return;
		}
		$this->view->paginator = $paginator = Zend_Paginator::factory ( Engine_Api::_ ()->kowcore ()->getRates ( $object, true ) );
		
		$paginator->setItemCountPerPage ( 30 );
		$paginator->setCurrentPageNumber ( $page );
		
		$this->view->html = $this->view->render ( 'smoothbox/list.tpl' );
	}
	
	public function ratersAction() {
		$guid = $this->_getParam ( 'guid', '' );
		if (! $guid) {
			$this->view->status = false;
			$this->view->message = $this->view->translate ( 'Correct parameters needed.' );
			return;
		}
		
		$this->view->object = $object = Engine_Api::_ ()->getItemByGuid ( $guid );
		if (! $object->getIdentity ()) {
			$this->view->status = false;
			$this->view->message = $this->view->translate ( 'Correct parameters needed.' );
			return;
		}
		
		$this->view->items = $paginator = Engine_Api::_ ()->kowcore ()->getRaters ( $object );
		$paginator->setItemCountPerPage ( 20 );
		
		$this->view->status = true;
		$this->view->html = $this->view->partial ( 'partials/fluent-list.tpl', 'kowcore', array ('paginator' => $paginator ) );
	}

}